<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use App\Http\Requests\SearchRequest;
use App\Http\Resources\ProductCategorysResource;
use App\Http\Resources\ProductResource;
use App\Models\Product;
use App\Models\ProductCategory;
use Illuminate\Auth\Events\Validated;
use Illuminate\Http\Request;

/**
 * Class ProductController
 * 商品控制器
 * @package App\Http\Controllers\Home
 */
class ProductController extends AbsController
{
    //
    public  function  search(SearchRequest $request,Product $product)
    {
        return $product->searchData($request->input('content'));
    }

    /**
     * 显示详情信息
     * @param Product $product
     * @return ProductResource
     */
    public function show(Product $product)
    {
        return (new ProductResource($product))
            ->additional(['category'=>$product->getCategoryInfo()]);
    }
}
